package com.by.controller;

import com.by.bean.ResultBean;
import com.by.bean.SupplierInquiry;
import com.by.group.V;
import com.by.mapper.SupplierInquiryMapper;
import com.by.query.SupplierInquiryInfo;
import com.by.service.SupplierInquiryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :LYJ
 * @version : 1.0
 * @date : 2025/2/25 14:18
 * @desc :
 * @since : JDK17
 */
@RestController
@RequestMapping("/api")
@Api(tags = "供应询价")
public class SupplierInquiryController extends BaseController {
    @Autowired
    SupplierInquiryService supplierInquiryService;
    @Autowired
    SupplierInquiryMapper supplierInquiryMapper;

    /**
     * 供应询价,多条件查询
     *
     * @param supplierInquiryInfo
     * @param result
     * @return
     */
    @PostMapping("/supplierInquiry/inquiry")
    @ApiOperation("供应商询价")
    public ResultBean quiryByInquiryInfo(@Validated @RequestBody SupplierInquiryInfo supplierInquiryInfo, BindingResult result) {
        V.validate(result);
        SupplierInquiry supplierInquiry1 = supplierInquiryService.quiryByInquiryInfo(supplierInquiryInfo);
        return success("success", supplierInquiry1);
    }

    @PostMapping("supplierInquiry/list")
    @ApiOperation("获取询价信息列表")
    public ResultBean quiryAll(@Validated @RequestBody SupplierInquiry supplierInquiry, BindingResult result) {
        V.validate(result);
        List<SupplierInquiry> supplierInquiries = supplierInquiryMapper.quiryAll(supplierInquiry);
        return success("success", supplierInquiries);
    }
}
